<template>
    <div id="header" >
        <div class="herderappshadow" @click="navcontentapprightmm"  :class="{'navcontentappshadow':navcontentappshadow}"></div>
        <div>
            <div class="herderapp" :class="{'navcontentappright':navcontentappright}">
                <div class="herderappimg"><img src="https://gitee.com/Cezzz/image2_repo/raw/master/img/20220114172154.jpg" ></div>
                <div class="herderappnum">
                    <div class="herderappnumitem">
                        <a href="#">
                            <div class="herderappnumitemname">Articles</div>
                            <div class="herderappnumitemnum">16</div>
                        </a>
                    </div>

                    <div class="herderappnumitem">
                        <a href="#">
                            <div class="herderappnumitemname">Tags</div>
                            <div class="herderappnumitemnum">16</div>
                        </a>
                    </div>

                    <div class="herderappnumitem">
                        <a href="#">
                            <div class="herderappnumitemname">Categories</div>
                            <div class="herderappnumitemnum">16</div>
                        </a>
                    </div>
                </div>
                <hr>
                <!-- app导航 -->
                <div class="herderappnavigation">
                    <div class="herderappnavigationcomtent" @click="navcontentapprightmm">
                        <router-link to="/" class="herderappnavigationcomtenta">
                            <i class="el-icon-s-home herderappnavigationcomtentai"></i>
                            <span >Home</span>
                        </router-link>
                    </div>

                    <div class="herderappnavigationcomtent" @click="navcontentapprightmm">
                        <router-link :to="{name:'publishArticle',query:{id:'message'}}" class="herderappnavigationcomtenta">
                            <i class="el-icon-s-comment herderappnavigationcomtentai"></i>
                            <span  @click="jumprecord">Message</span>
                        </router-link>
                    </div>

                    <div class="herderappnavigationcomtent" @click="navcontentapprightmm">
                        <router-link to="/recored" class="herderappnavigationcomtenta">
                            <i class="el-icon-s-help herderappnavigationcomtentai"></i>
                            <span  @click="jumprecord">Share</span>
                        </router-link>
                    </div>
                </div>
            </div>
            
        </div>


        <header class="Herder"  style="background-image:url('https://gitee.com/Cezzz/image2_repo/raw/master/img/20220114172154.jpg')">
            <nav class="navigation" :class="{'isFixedtop':isFixed,'isFixednotop':isFixednotop}">
                <span><router-link class="navname" to="/">c</router-link></span>
                <div class="navdata">
                    <div class="navcontent">
                        <div class="Home">
                            <router-link class="aHome" to="/">
                                <i class="el-icon-s-home"></i>
                                <span >Home</span>
                            </router-link>
                                
                        </div>
                        <div class="record">
                            <router-link class="aRecord"  to="/recored">
                                <i class="el-icon-orange"></i>
                                <span @click="jumprecord">Record</span>
                            </router-link>
                                
                        </div>  
                        <div class="Issue">
                            <router-link class="aIssue" :to="{name:'publishArticle',query:{id:'message'}}">
                                <i class="el-icon-position"></i>
                                <span @click="jumprecord">Issue</span>
                            </router-link>
                                
                        </div>
                        <div class="Classify">
                            <a class="aClassify" href="#">
                                <i class="el-icon-folder-opened"></i>
                                <span>Classify</span>
                            </a>
                                
                        </div>
                        <div class="Music">
                            <a class="aMusic" href="#">
                                <i class="el-icon-headset"></i>
                                <span>Music</span>
                            </a>
                                
                        </div>
                        <div class="More">
                            <router-link class="aMore" to="/">
                                <i class="el-icon-menu"></i>
                                <span>More</span>
                            </router-link>
                                
                        </div>
                    </div>
                    <div class="navcontentapp navcontent"><a @click="navcontentapprightmm" href="#"><i class="el-icon-s-unfold"></i></a></div>
                </div>
            </nav>
            <div>
                <div class="herderbottom">
                    <i class="el-icon-minus iherderbottom" @click="jumprecord"></i>
                </div>
            </div>
        </header>
        <div id="mmp"></div>
    </div>
</template>

<script>
export default {
    name:"HerderTop",
    data(){
        return{
            navcontentappright:false,
            navcontentappshadow:false,
            isFixednotop:false,
            isFixed:true,
        }
    },
    mounted () {
      window.addEventListener('scroll',this.handleScroll)  // 监听滚动事件，然后用handleScroll这个方法进行相应的处理
    },
    
    methods: {
        navcontentapprightmm(){

            this.navcontentappright=!this.navcontentappright,
            this.navcontentappshadow=!this.navcontentappshadow
            
            
        },
        handleScroll(){
            let scrollTop=window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop// 滚动条偏移量
            let offsetTop=document.querySelector('#header').offsetTop; // 要滚动到顶部吸附的元素的偏移量
            if(scrollTop>offsetTop){
                this.isFixednotop=true
                this.isFixed=false
            }else{
                this.isFixednotop=false
                this.isFixed=true
            }
        },
        jumprecord(){
            
            document.querySelector("#mmp").scrollIntoView({behavior:"smooth",block:"start"})
        }
    }
}
</script>

<style>
    :root{
            --herderapp-bg: #f6f8fa;
            --herderapp-co:#4c4948;
    }
    .herderappnavigation{
        padding: 0 10px 40px;
    }
    @media screen and (max-width:768px){
        .navcontentapp{
            display: block !important;
            font-size: 1.4em;
        }
        .navigation{
            padding: 0 15px !important;
        }
        
        
    }
    
    @media screen and (min-width:768px){
        .navcontentapp{
            display: none !important;
            font-size: 1.4em;
        }
    }
    @media screen and (max-width:768px){
        .navcontent{
            display: none;
        }
    }
    .herderappnavigationcomtentai{
        width: 15%;
        font-size: 1.15em;
        text-align: left;
    }
    .herderappnavigationcomtent:hover{
        background: #7cc6f7;
        transition: all .5s;
        -webkit-transition: all .5s;
        -moz-transition: all .5s;
        -ms-transition:all .5s;
        -o-transition: all .5s;
    }
    .herderappnavigationcomtenta{
        position: relative;
        outline: none;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
        -webkit-decoration:none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -moz-user-focus: none;
        transition: all 1s;
        -webkit-transition: all 1s;
        -moz-transition: all 1s;
        -o-transition: all 1s;
        -ms-transition:all 1s;

        display: block;
        padding: 6px 30px 6px 22px;
        color: var(--herderapp-co);
        font-size: 1.15em;
    }
    .navcontentappright{
        
        transition: all 1s !important;
        -webkit-transition: 1s !important;
        -moz-transition: all 1s !important;
        -o-transition: all 1s !important;
        right: 0px !important;
    }
    .navcontentappshadow{
        display: block !important;
        transition: all .5s !important;
        -webkit-transition: all.5s !important;
        -moz-transition: all .5s !important;
        -o-transition: all .5s !important;
    }
    

    .herderappnumitem a{
        background: transparent;
        outline: none;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
        -webkit-decoration:none;
        /* -webkit-user-select: none; */
        -moz-user-focus: none;
        /* -moz-user-select: none; */
    }
    .herderappnumitemnum{
        color: #1f2d3d;
        font-size: 1.28em;
    }
    .herderappnumitemname{
        color:#4c4948 ;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .herderappnumitem{
        display: table-cell;
        text-align: center;
    }
    .herderappnum{
        display: table;
        padding: 0 10px;
        width: 100%;
        table-layout: fixed;
        text-align: center;
    }
    .herderappimg > :nth-child(1){
        -webkit-animation: sidebarItem .2s;
        animation: sidebarItem .2s;
        -moz-animation: sidebarItem .2s;
        -o-animation: sidebarItem .2s;
    }
   
    .herderappimg img{
        width: 100%;
        height: 100%;
        -webkit-transition: filter 375ms ease-in 1s, -webkit-transform .3s;
        -moz-transition: filter 375ms ease-in 1s, -moz-transform .3s;
        -o-transition: filter 375ms ease-in 1s, -o-transform .3s;
        -ms-transition:filter 375ms ease-in 1s, -ms-transform .3s;
        transition: filter 375ms ease-in 1s, transform .3s;
        object-fit: cover;
    }
    .herderappimg{
        margin: 20px auto;
        overflow: hidden;
        width: 110px;
        height: 110px;
        border-radius: 70px;
        text-align: center;

    }
    .herderappshadow {
        position: fixed;
        overflow-x:hidden;
        overflow-y:scroll;
        z-index: 10000;
        display: none;
        overflow-x: hidden;
        overflow-y: scroll;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.8);
    }

    .herderapp {
        position: fixed;
        top: 0;
        right: -300px;
        
        z-index: 10001;
        overflow-x: hidden;
        overflow-y: scroll;
        width: 300px;
        height: 100%;
        background: var(--herderapp-bg);
        transition: all 1s;
        -webkit-transition: all 1s;
        -moz-transition: all 1s;
        -o-transition: all 1s;
        -ms-transition:all 1s;
        
    }
    
    .iherderbottom{
        position: relative;
        width: 100%;
        /* 动画先加速在减速 */
        animation-timing-function: ease-in-out;
        /* 设置动画延时 */
        animation-delay: 2s;
        /* 当前元素关键字名字 */
        animation-name:herdertd ;
        /* 动画执行时间 */
        animation-duration: 2s;
        /* 动画执行的次数 infinite无限次 */
        animation-iteration-count: infinite;
        
        animation-direction: alternate;
    }
    @keyframes herdertd{
        0%{
            top: 0;
            opacity: 1;
        }/* 表示动画开始*/
        50%{
            top: -16px;
            opacity: 0.4;
            filter: none;    
        }    /* 表示动画结束位置 */
        100%{
            top: 0;
            opacity: 1;
            -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
            filter: alpha(opacity=40);
        }
    }
    .herderbottom{
        position: absolute;
        bottom: 0;
        width: 100%;
        cursor: pointer;
        z-index: 9999;
        text-align: center;
        font-size: 1.5em;
    }
    .isFixedtop{
        
        transform: translate(0);
        transition: transform .5s;
        position: fixed;
        
        width: 100%;
        
    }
    .isFixednotop{
        
        transition: all 2s;
        
        transform: translate(0,-53px);
        
    }
    .Herder{
        background-image: url('https://gitee.com/Cezzz/image2_repo/raw/master/img/20220114172154.jpg');
        height: 100vh;
        background-attachment: fixed;
        position: relative;
        width: 100%;
        background-color:aquamarine;
        background-position: center center;
        background-size: cover;
        background-repeat: no-repeat;
        transition: all 0.5s;
        animation: header-effect 1s;
        
        
}
    .Herder:not(.not-top-img):before {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.3);
    content: '';
}
    .navigation{
        box-sizing: border-box;
        width:100% ;
        height: 60px;
        font-size: 1.5em;
        position: absolute;
        display: flex;
        /* background: chartreuse; */
        padding: 0 35px;
        transition: all 1s;
        align-items: center;
    }
    .Herder .navname{
        cursor: pointer;
        font-weight: bold;
        text-decoration: none;
        color: #eee;
        text-shadow: 2px 2px 4px rgb(0 0 0 / 15%);
    }
    .navcontent a{
        color: #eee;
        text-decoration: none;
        display: inline;
        
    }
    .Home{
        position: relative;
        display: inline-block;
        padding: 0 0 0 14px;
    }
    .record{
        position: relative;
        display: inline-block;
        padding: 0 0 0 14px;
    }
    .Issue{
        position: relative;
        display: inline-block;
        padding: 0 0 0 14px;
    }
    .Classify{
        position: relative;
        display: inline-block;
        padding: 0 0 0 14px;
    }
    .Music{
        position: relative;
        display: inline-block;
        padding: 0 0 0 14px;
    }
    .More{
        position: relative;
        display: inline-block;
        padding: 0 0 0 18px;
    }
    .navdata{
        margin-left: auto;
        font-size: 0.7em;
        text-shadow: 2px 2px 4px rgb(0 0 0 / 15%);
    }
    .aHome:not(.child):after{
        position: absolute;
        bottom: 0;
        left: 0;
        z-index: 1;
        width: 0;
        height: 3px;
        background-color: #80c8f8;
        content: '';
        
        transition: all 0.3s ease-in-out;
    }
    .aHome:not(.child):hover:after{
        width: 100%;
    }
    .aHome{
        position: relative;
        padding-bottom: 6px;
    }

    .aRecord:not(.child):after{
        position: absolute;
        bottom: 0;
        left: 0;
        z-index: 1;
        width: 0;
        height: 3px;
        background-color: #80c8f8;
        content: '';
        
        transition: all 0.3s ease-in-out;
    }
    .aRecord:not(.child):hover:after{
        width: 100%;
    }
    .aRecord{
        position: relative;
        padding-bottom: 6px;
    }
    .aIssue:not(.child):after{
        position: absolute;
        bottom: 0;
        left: 0;
        z-index: 1;
        width: 0;
        height: 3px;
        background-color: #80c8f8;
        content: '';
        
        transition: all 0.3s ease-in-out;
    }
    .aIssue:not(.child):hover:after{
        width: 100%;
    }
    .aIssue{
        position: relative;
        padding-bottom: 6px;
    }
    .aClassify:not(.child):after{
        position: absolute;
        bottom: 0;
        left: 0;
        z-index: 1;
        width: 0;
        height: 3px;
        background-color: #80c8f8;
        content: '';
        
        transition: all 0.3s ease-in-out;
    }
    .aClassify:not(.child):hover:after{
        width: 100%;
    }
    .aClassify{
        position: relative;
        padding-bottom: 6px;
    }
    .aMusic:not(.child):after{
        position: absolute;
        bottom: 0;
        left: 0;
        z-index: 1;
        width: 0;
        height: 3px;
        background-color: #80c8f8;
        content: '';
        
        transition: all 0.3s ease-in-out;
    }
    .aMusic:not(.child):hover:after{
        width: 100%;
    }
    .aMusic{
        position: relative;
        padding-bottom: 6px;
    }
    .aMore:not(.child):after{
        position: absolute;
        bottom: 0;
        left: 0;
        z-index: 1;
        width: 0;
        height: 3px;
        background-color: #80c8f8;
        content: '';
        
        transition: all 0.3s ease-in-out;
    }
    .aMore:not(.child):hover:after{
        width: 100%;
    }
    .aMore{
        position: relative;
        padding-bottom: 6px;
    }
</style>